<?php
namespace Amis\form;
class Table extends FormItem
{
    public string $type = 'input-table';

    public function addable(bool $addable = false)
    {
        $this->addable = $addable;
        return $this;
    }

    public function editable(bool $editable = false)
    {
        $this->editable = $editable;
        return $this;
    }

    public function removable(bool $removable = false)
    {
        $this->removable = $removable;
        return $this;
    }

    public function showAddBtn(bool $showAddBtn = true)
    {
        $this->showAddBtn = $showAddBtn;
        return $this;
    }

    public function addApi(string $addApi)
    {
        $this->addApi = $addApi;
        return $this;
    }

    public function updateApi(string $updateApi)
    {
        $this->updateApi = $updateApi;
        return $this;
    }

    public function deleteApi(string $deleteApi)
    {
        $this->deleteApi = $deleteApi;
        return $this;
    }

    public function addBtnLabel(string $addBtnLabel)
    {
        $this->addBtnLabel = $addBtnLabel;
        return $this;
    }

    public function addBtnIcon(string $addBtnIcon = 'plus')
    {
        $this->addBtnIcon = $addBtnIcon;
        return $this;
    }

    public function copyBtnLabel(string $copyBtnLabel)
    {
        $this->copyBtnLabel = $copyBtnLabel;
        return $this;
    }

    public function copyBtnIcon(string $copyBtnIcon = 'copy')
    {
        $this->copyBtnIcon = $copyBtnIcon;
        return $this;
    }

    public function editBtnLabel(string $editBtnLabel = '')
    {
        $this->editBtnLabel = $editBtnLabel;
        return $this;
    }

    public function editBtnIcon(string $editBtnIcon = 'pencil')
    {
        $this->editBtnIcon = $editBtnIcon;
        return $this;
    }

    public function deleteBtnLabel(string $deleteBtnLabel = '')
    {
        $this->deleteBtnLabel = $deleteBtnLabel;
        return $this;
    }

    public function deleteBtnIcon(string $deleteBtnIcon = 'minus')
    {
        $this->deleteBtnIcon = $deleteBtnIcon;
        return $this;
    }

    public function confirmBtnLabel(string $confirmBtnLabel = '')
    {
        $this->confirmBtnLabel = $confirmBtnLabel;
        return $this;
    }

    public function confirmBtnIcon(string $confirmBtnIcon = 'check')
    {
        $this->confirmBtnIcon = $confirmBtnIcon;
        return $this;
    }

    public function cancelBtnLabel(string $cancelBtnLabel = '')
    {
        $this->cancelBtnLabel = $cancelBtnLabel;
        return $this;
    }

    public function cancelBtnIcon(string $cancelBtnIcon = 'times')
    {
        $this->cancelBtnIcon = $cancelBtnIcon;
        return $this;
    }

    /**
     * 是否需要确认操作，，可用来控控制表格的操作交互
     * @param bool $needConfirm
     * @return $this
     */
    public function needConfirm(bool $needConfirm = true)
    {
        $this->needConfirm = $needConfirm;
        return $this;
    }

    /**\是否可以访问父级数据，也就是表单中的同级数据，通常需要跟 strictMode 搭配使用
     * @param bool $canAccessSuperData
     * @return $this
     */
    public function canAccessSuperData(bool $canAccessSuperData = false)
    {
        $this->canAccessSuperData = $canAccessSuperData;
        return $this;
    }

    /**
     * 为了性能，默认其他表单项项值变化不会让当前表格更新，有时候为了同步获取其他表单项字段，需要开启这个。
     * @param bool $strictMode
     * @return $this
     */
    public function strictMode(bool $strictMode = true)
    {
        $this->strictMode = $strictMode;
        return $this;
    }

    /**
     * columns    array    []    列信息
     * columns[x].quickEdit    boolean 或者 object    -    配合 editable 为 true 一起使用
     * columns[x].quickEditOnUpdate    boolean 或者 object    -    可以用来区分新建模式和更新模式的编辑配置
     * @param array $strictMode
     * @return $this
     */
    public function columns(array $strictMode)
    {
        $this->columns = $strictMode;
        return $this;
    }
}